package com.yy.wga.goods.service.common.constant;

import lombok.Data;

@Data
public class RedisConstants {

    private static final String PREFIX = "wga:";

    private static final String HEAD_SUPPLIER_GOODS_KEYS = "headSupplierGoodsInfo:";
    private static final String PROMOTE_GOODS_KEYS = "promoteGoodsInfo:";

    private static final String HEAD_SUPPLIER_GOODS_LIST_KEYS = "headSupplierGoodsList";


    private static final String getAppKeyPrefix(String appKey) {
        return PREFIX + appKey + ":";
    }

    private static String keyConcat(String... keys) {
        StringBuilder sb = new StringBuilder();
        for (String key : keys) {
            sb.append(key).append(":");
        }
        return sb.substring(0, sb.length() - 1);
    }

    public static String getHeadSupplierGoodsKey(String appKey, String shopAppId, String productId) {
        return getAppKeyPrefix(appKey) + HEAD_SUPPLIER_GOODS_KEYS + keyConcat(shopAppId, productId);
    }

    public static String getPromoteGoodsKey(String appKey, String shopAppId, String productId) {
        return getAppKeyPrefix(appKey) + PROMOTE_GOODS_KEYS + keyConcat(shopAppId, productId);
    }


    public static String getHeadSupplierGoodsListKey(String appKey) {
        return getAppKeyPrefix(appKey) + HEAD_SUPPLIER_GOODS_LIST_KEYS;
    }

    public static String getHeadSupplierGoodsListTempKey(String appKey) {
        return getAppKeyPrefix(appKey) + HEAD_SUPPLIER_GOODS_LIST_KEYS + ":temp";
    }

}
